package com.hlkj.pay.enums;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import com.hlkj.framework.common.valid.IValidEnum;
import com.hlkj.framework.common.valid.IValidStringEnum;

import lombok.Getter;
/**
 * @author HlpayTeam
 * @date 2024/09/12 15:27
 */
public interface PayEnums {
	@Getter
	enum CHANGE_LOG_TYPE {

		//1 用户 2 角色 3 权限 4 组织
		PAY_WAY(1, "支付方式"),
		CHANNEL(2, "支付渠道"),
		PROVIDER_INFO(3, "服务商信息"),
		PROVIDER_CONFIG(4, "服务商配置"),
		PROVIDER_FEE(5, "服务商费率"),

		;

		/**
		 * 错误码
		 */
		private Integer code;
		/**
		 * 错误提示
		 */
		private String  msg;

		CHANGE_LOG_TYPE(Integer code, String msg){
			this.code = code;
			this.msg = msg;
		}

		public static CHANGE_LOG_TYPE from(Integer key) {
			CHANGE_LOG_TYPE[] values = CHANGE_LOG_TYPE.values();
			for (CHANGE_LOG_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(key)) {
					return deliveryType;
				}
			}
			return CHANGE_LOG_TYPE.PAY_WAY;
		}
	}
	//WECHAT: 微信 ALIPAY: 支付宝 UNION_APY: 云闪付 DIGITAL: 数字人民币
	@Getter
	enum PAY_TYPE implements IValidEnum {
		//1 微信 2 支付宝 3 云闪付 4 数字人民币 5 快捷 6 网银 7 功能 8 其他
		WECHAT(1,"WECHAT","微信"),
		ALIPAY( 2,"ALIPAY","支付宝"),
		UNION_APY(3,"UNION_APY","云闪付"),
		DIGITAL( 4,"DIGITAL","数字人民币"),
		QUICK( 5,"QUICK","快捷"),
		ONLINE(6,"ONLINE","网银"),
		FUNCTION(7,"FUNCTION","功能"),
		OTHER(8,"OTHER","其他"),
		JDBT(9,"JDBT","京东白条"),
		BANKTRANSFER(10,"BANKTRANSFER","银行转账"),

		;

		/**
		 * 错误码
		 */
		private Integer code;
		/**
		 * 支付类型
		 */
		private String type;
		/**
		 * 错误提示
		 */
		private String desc;


		PAY_TYPE(Integer code,String type,String desc) {
			this.code = code;
			this.type = type;
			this.desc = desc;
		}

		public static PAY_TYPE fromByCode(Integer code) {
			PAY_TYPE[] values = PAY_TYPE.values();
			for (PAY_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(code)) {
					return deliveryType;
				}
			}
			return null;
		}
		public static PAY_TYPE fromByType(String type) {
			PAY_TYPE[] values = PAY_TYPE.values();
			for (PAY_TYPE deliveryType : values) {
				if (deliveryType.getType().equals(type)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	//支付方式 Native- 扫码支付； JSAPI-微信JSAPI、支付宝JSAPI支付、银联JSAPI支付； SIMPLE-简易支付 MINI_APP-微信小程序支付、支付宝小程序支付 H5-h5 支付 APP-APP 支付
	@Getter
	enum SCENE_PAY_TYPE implements IValidStringEnum {
		//1 微信 2 支付宝 3 云闪付 4 数字人民币 5 快捷 6 网银 7 功能 8 其他
		QR("Qr","NATIVE",1,"扫码支付-正扫 c-b"),
		SCAN("Scan","SCAN",2,"扫码支付-反扫 b-c"),
		H5("H5","H5",1,"h5 支付"),
		PC("Pc","PC",1,"电脑支付"),
		WAP("Wap","H5",1,"h5 支付"),
		APP("App","APP",1,"APP 支付"),
		JSAPI("Pub","JSAPI",1,"公众号"),
		MINI_APP("Lite","MINI_APP",1,"小程序"),
		SIMPLE("quickPay","SIMPLE",1,"简易支付"),

		;

		/**
		 * 错误码
		 */
		private String code;
		/**
		 * 支付类型
		 */
		private String type;
		/**
		 * 支付类型
		 */
		private Integer sceneType;
		/**
		 * 错误提示
		 */
		private String desc;


		SCENE_PAY_TYPE(String code,String type,Integer sceneType,String desc) {
			this.code = code;
			this.type = type;
			this.sceneType = sceneType;
			this.desc = desc;
		}

		public static SCENE_PAY_TYPE from(String key) {
			SCENE_PAY_TYPE[] values = SCENE_PAY_TYPE.values();
			for (SCENE_PAY_TYPE deliveryType : values) {
				if (deliveryType.getType().equals(key)) {
					return deliveryType;
				}
			}
			return null;
		}
		public static SCENE_PAY_TYPE fromByCode(String code) {
			SCENE_PAY_TYPE[] values = SCENE_PAY_TYPE.values();
			for (SCENE_PAY_TYPE scenePayType : values) {
				if (code.endsWith(scenePayType.getCode())) {
					return scenePayType;
				}
			}
			return null;
		}
		public static SCENE_PAY_TYPE fromByType(String type,Integer sceneType) {
			SCENE_PAY_TYPE[] values = SCENE_PAY_TYPE.values();
			for (SCENE_PAY_TYPE deliveryType : values) {
				if (deliveryType.getType().equals(type)&&deliveryType.getSceneType().equals(sceneType)) {
					return deliveryType;
				}
			}
			return fromByType(type);
		}
		public static SCENE_PAY_TYPE fromByType(String type) {
			SCENE_PAY_TYPE[] values = SCENE_PAY_TYPE.values();
			for (SCENE_PAY_TYPE deliveryType : values) {
				if (deliveryType.getType().equals(type)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	@Getter
	enum FEE_TYPE implements IValidEnum {
		//1 百分比 2 固定值 3 百分比+固定值
		PERCENTAGE(1, "百分比"), FIXED_VALUE(2,  "固定值"), UNION(3,  "百分比+固定值"),

		;

		/**
		 * 错误码
		 */
		private Integer code;

		/**
		 * 错误提示
		 */
		private String desc;

		FEE_TYPE(Integer code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static FEE_TYPE from(Integer code) {
			FEE_TYPE[] values = FEE_TYPE.values();
			for (FEE_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(code)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	@Getter
	enum SCENE_TYPE implements IValidEnum {
		//1 线下 2 线上
		OFFLINE(1,"线下"),
		ONLINE(2,"线上"),
		ALL(3,"ALL"),



		;


		/**
		 * 错误码
		 */
		private Integer code;

		/**
		 * 错误提示
		 */
		private String desc;

		SCENE_TYPE(Integer code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static SCENE_TYPE from(Integer key) {
			SCENE_TYPE[] values = SCENE_TYPE.values();
			for (SCENE_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(key)) {
					return deliveryType;
				}
			}
			return null;
		}

		public static SCENE_TYPE fromName(String name) {
			SCENE_TYPE[] values = SCENE_TYPE.values();
			for (SCENE_TYPE deliveryType : values) {
				if (deliveryType.name().equals(name)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	@Getter
	enum ACCESS_SCENE_TYPE implements IValidEnum {
		//1 线下 2 线上
		WEB(1,"网站"),
		PHONE(2,"手机端"),
		OFFLINE(3,"线下场景"),
		;

		/**
		 * 错误码
		 */
		private Integer code;

		/**
		 * 错误提示
		 */
		private String desc;

		ACCESS_SCENE_TYPE(Integer code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static ACCESS_SCENE_TYPE from(Integer key) {
			ACCESS_SCENE_TYPE[] values = ACCESS_SCENE_TYPE.values();
			for (ACCESS_SCENE_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(key)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	@Getter
	enum DICT_KEY implements IValidStringEnum {
		//certType：证件类型 licenseType：机构证照类型  companyType：公司类型 areaCode：区域
		//1 线下 2 线上
		AREA_CODE("areaCode","区域"),
		MCC_CATEGORY("mccCategory","行业分类"),
		BENEFICIARY_MODE("beneficiaryMode","受益方式"),
		BANK_CODE("bankCode","银行编码"),
		BANK_CITY_CODE("bankCityCode","银行城市编码"),
		MCC_WECHAT("mccWechat","微信行业分类"),
		MCC_ALIPAY("mccAlipay","支付宝行业分类"),


		;


		/**
		 * 错误码
		 */
		private String code;

		/**
		 * 错误提示
		 */
		private String desc;

		DICT_KEY(String code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static DICT_KEY from(String key) {
			DICT_KEY[] values = DICT_KEY.values();
			for (DICT_KEY deliveryType : values) {
				if (deliveryType.getCode().equals(key)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	@Getter
	enum COMMON_DICT_KEY implements IValidStringEnum {
		LAKALA("lakala","拉卡拉",true,"secondLevel"),
		HEEPAY("heepay","汇付宝",true,""),
		GTZFPAY("gtzfpay","国通支付",true,""),
		HELIPAY("helipay","合利宝",true,""),
		WXPAY("wxpay","微信",true,""),
		YEEPAY("yeepay","易宝",true,""),
		HNAPAY("hnapay","新生",true,""),


		;

		/**
		 * 错误码
		 */
		private String code;
		/**
		 * 错误码
		 */
		private String desc;

		/**
		 * 是否重新加载认证
		 */
		private boolean reloadAuth;
		/**
		 * 是否重新加载认证
		 */
		private String bankCodeParentKey;

		COMMON_DICT_KEY(String code, String desc,boolean reloadAuth,String bankCodeParentKey) {
			this.code = code;
			this.desc = desc;
			this.reloadAuth = reloadAuth;
			this.bankCodeParentKey = bankCodeParentKey;
		}

		public static COMMON_DICT_KEY from(String key) {
			COMMON_DICT_KEY[] values = COMMON_DICT_KEY.values();
			for (COMMON_DICT_KEY commonDictKey : values) {
				if (commonDictKey.getCode().equals(key)) {
					return commonDictKey;
				}
			}
			return null;
		}
	}
	@Getter
	enum CHANNEL_REQUEST_TYPE {
		//certType：证件类型 licenseType：机构证照类型  companyType：公司类型 areaCode：区域
		//1 线下 2 线上
		MERCHANT_ACCESS(1,"商户进件"),
		PAY_ORDER(2,"支付订单"),
		AD_PAY_ORDER(3,"广告订单"),
		PAYMENT(4,"代付"),
		PROFIT_ORDER(5,"分润订单"),
		FUND_ACCOUNT(6,"分润账号"),
		MERCHANT_SETTLE(7,"商户结算"),
		SUBSIDY_ORDER(8,"营销补贴订单"),


		;


		/**
		 * 错误码
		 */
		private Integer code;

		/**
		 * 错误提示
		 */
		private String desc;

		CHANNEL_REQUEST_TYPE(Integer code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static CHANNEL_REQUEST_TYPE from(Integer key) {
			CHANNEL_REQUEST_TYPE[] values = CHANNEL_REQUEST_TYPE.values();
			for (CHANNEL_REQUEST_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(key)) {
					return deliveryType;
				}
			}
			return null;
		}
	}
	@Getter
	//1；app，2:h5 3:微信小程序/公众号 4:支付宝生活号/小程序
	enum SCENE_SUB_TYPE implements IValidEnum {
		//1 微信 2 支付宝 3 云闪付 4 数字人民币 5 快捷 6 网银 7 功能 8 其他
		NO_MAIN_RECORD(0,"非主体备案"),
		MAIN_RECORD (1,"主体备案"),
		APP(2,"app"),
		H5(3,"h5"),
		WECHAT(4,"微信小程序/公众号"),
		ALIPAY(5,"支付宝生活号/小程序"),

		;

		/**
		 * 错误码
		 */
		private Integer code;
		/**
		 * 错误提示
		 */
		private String desc;


		SCENE_SUB_TYPE(Integer code,String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static SCENE_SUB_TYPE from(String code) {
			SCENE_SUB_TYPE[] values = SCENE_SUB_TYPE.values();
			for (SCENE_SUB_TYPE deliveryType : values) {
				if (deliveryType.getCode().equals(code)) {
					return deliveryType;
				}
			}
			return null;
		}
	}

	@Getter
	enum LIMIT_SCENE_TYPE implements IValidEnum {
		EBANK(0,"收银台只展示网银支付模块"),
		EBANK_B2C(1,"收银台只展示网银支付模块且只展示B2C"),
		EBANK_B2B(2,"收银台只展示网银支付模块且只展示B2B"),
		;

		/**
		 * 错误码
		 */
		private Integer code;

		/**
		 * 错误提示
		 */
		private String desc;

		LIMIT_SCENE_TYPE(Integer code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static LIMIT_SCENE_TYPE from(Integer key) {
			LIMIT_SCENE_TYPE[] values = LIMIT_SCENE_TYPE.values();
			for (LIMIT_SCENE_TYPE type : values) {
				if (type.getCode().equals(key)) {
					return type;
				}
			}
			return EBANK;
		}
	}

	@Getter
	enum CHECK_SCENE_TYPE implements IValidEnum {
		REMARKCODE(1,"固定账户号+动态附言模式"),
		ACCOUNTNO(2,"动态账户号模式"),
		;

		/**
		 * 错误码
		 */
		private Integer code;

		/**
		 * 错误提示
		 */
		private String desc;

		CHECK_SCENE_TYPE(Integer code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public static CHECK_SCENE_TYPE from(Integer key) {
			CHECK_SCENE_TYPE[] values = CHECK_SCENE_TYPE.values();
			for (CHECK_SCENE_TYPE type : values) {
				if (type.getCode().equals(key)) {
					return type;
				}
			}
			return ACCOUNTNO;
		}
	}
}
